package com.vvlive.caibao.smartcity.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by zhj on 2015/6/29.
 */
public class TimeUtil {

    public final static String DATE_FORMAT = "yyyy-MM-dd";
    public final static String TIME_FORMAT = "HH:mm";
    private final static String BLANK = " ";
    private final static String DATE_TIME_FORMAT = DATE_FORMAT + BLANK + TIME_FORMAT;

    public static String getCurrentDate(){
        return getCurrentDate(DATE_FORMAT);
    }

    public static String getCurrentDate(String dateFormat){
        return new SimpleDateFormat(dateFormat).format(new Date());
    }

    public static String getCurrentTime(){
        return getCurrentTime(TIME_FORMAT);
    }

    public static String getCurrentTime(String timeFormat){
        return new SimpleDateFormat(timeFormat).format(new Date());
    }

    public static String getCurrentDateTime(){
        return getCurrentDateTime(DATE_TIME_FORMAT);
    }

    public static String getCurrentDateTime(String dateTimeFormat){
        return new SimpleDateFormat(dateTimeFormat).format(new Date());
    }

    public static String getTargetDate(long time){
        return getTargetDate(time, DATE_FORMAT);
    }

    public static String getTargetDate(long time, String dateFormat){
        return new SimpleDateFormat(dateFormat).format(new Date(time));
    }

    public static String getTargetDateTime(long time){
        return getTargetDateTime(time, DATE_TIME_FORMAT);
    }

    private static String getTargetDateTime(long time, String dateTimeFormat) {
        return new SimpleDateFormat(dateTimeFormat).format(new Date(time));
    }

}
